import org.apache.commons.lang.WordUtils

class TradeService {

    Collection findOrCreateTrades(String tradeStr) {

        def trades = []
        tradeStr.split(', ').each{
            def trade = Trade.findByITradeName(it)
            if(trade) {
                trades << trade
            } else {
                trade = new Trade(tradeName:WordUtils.capitalize(it))
                trade.save()
                trades << trade
            }

        }
        return trades
    }

}